package com.whut.transportation;

import java.util.HashMap;

import com.whut.transportation.entity.TaskInfo;
import com.whut.transportation.entity.TransInfo;
import com.whut.transportation.network.HttpManager;
import com.whut.transportation.network.HttpRequestVo;
import com.whut.transportation.parser.JSONParser;
import com.whut.transportation.ui.BaseActivity;
import com.whut.transportation.ui.BaseActivity.DataCallback;
import com.whut.transportation.utils.Constant;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
//提交成功界面
public class SuccessActivity extends BaseActivity {
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.button1:
			submit();
			break;
		default:
			break;
		}
		super.onClick(v);
	}

	private TextView unload_number;
	private TextView unload_trainNum;
	private TextView unload_train;
	private TextView unload_station;
	private TextView unload_goods;
	private TextView unload_name;
	private TextView unload_weight;
	private TextView unload_gudao;
	private TextView unload_time;
	private TextView unload_begin_time;
	private TextView unload_end_time;
	private TextView unload_buNum;
	
	private Button back;
	
	
	
	private TransInfo transinfo;
	private TaskInfo taskInfo;
	
	private SharedPreferences preferences;
	
	private String  gudaoId;
	@Override
	protected void loadViewLayout() {
		setContentView(R.layout.activity_success);
		Intent intent = getIntent();
		transinfo = (TransInfo)intent.getSerializableExtra("transinfo");
		taskInfo = (TaskInfo) intent.getSerializableExtra("taskInfo");
		preferences=getSharedPreferences("userId", Context.MODE_PRIVATE);
		//类型为1时为装车  0为卸车
		String tag = "卸车";
		if(transinfo.getType()==0)
			tag = "装车";
		setTitleBarView(true, tag+"信息提交成功", -1, true);
	}
	
	@Override
	protected void findViewById() {
		unload_number = (TextView) findViewById(R.id.unload_number);
		unload_trainNum = (TextView) findViewById(R.id.unload_trainNum);
		unload_train = (TextView) findViewById(R.id.unload_train);
		unload_station = (TextView) findViewById(R.id.unload_station);
		unload_goods = (TextView) findViewById(R.id.unload_goods);
		unload_name = (TextView) findViewById(R.id.unload_name);
		unload_weight = (TextView) findViewById(R.id.unload_weight);
		unload_gudao = (TextView) findViewById(R.id.unload_gudao);
		unload_time = (TextView) findViewById(R.id.unload_time);
		unload_begin_time = (TextView) findViewById(R.id.unload_begin_time);
		unload_end_time = (TextView) findViewById(R.id.unload_end_time);
		unload_buNum = (TextView) findViewById(R.id.unload_buNum);
		back = (Button) findViewById(R.id.button1);
	}

	@Override
	protected void afterFindViewId() {
		unload_number.setText(unload_number.getText()+transinfo.getNumber());
		unload_trainNum.setText(unload_trainNum.getText()+transinfo.getTrainNumber());
		unload_train.setText(unload_train.getText()+transinfo.getTrain());
		unload_station.setText(unload_station.getText()+transinfo.getStation());
		unload_goods.setText(unload_goods.getText()+transinfo.getGoods());
		unload_name.setText(unload_name.getText()+transinfo.getName());
		unload_weight.setText(unload_weight.getText()+String.valueOf(transinfo.getWeight()+"t"));
		unload_gudao.setText(unload_gudao.getText()+String.valueOf(transinfo.getGudao()));
		unload_time.setText(unload_time.getText()+String.valueOf(taskInfo.getIntime()));
		unload_begin_time.setText(unload_begin_time.getText()+String.valueOf(taskInfo.getBegintime()));
		unload_end_time.setText(unload_end_time.getText()+String.valueOf(taskInfo.getEndtime()));
		unload_buNum.setText(unload_buNum.getText()+String.valueOf(taskInfo.getBunum()));
	}
	
	@Override
	protected void processLogic() {
		
	}
	
	private void submit(){
		Intent intent = new Intent(this, CarCheckSecondActivity.class);
		intent.putExtra("transinfo", transinfo);
		startActivity(intent);
	}

	@Override
	protected void setListener() {
		back.setOnClickListener(this);
	}

	@Override
	protected void getDataAgain() {
		
	}

}
